//
//  PersonCollectionView.m
//  DemoV2
//
//  Created by 董一龙 on 2022/6/25.
//
#import "../../Common.h"
#import "PersonChannelView.h"

@interface PersonChannelView ()

@end


/// 必须使用initWithFrame初始化
@implementation PersonChannelView

- (instancetype)initWithFrame:(CGRect)frame{
    if(self = [super initWithFrame:frame]){
        [self initUI:frame];
    }
    return self;
}

# pragma mark - PRIVATE

- (void)initUI:(CGRect)frame{
    self.backgroundColor = [UIColor yellowColor];
    
    // 编辑按钮
    CGFloat buttonHeight = 30;
    self.editButton = [UIButton new];
    self.editButton.frame = CGRectMake(SCREEN_WIDTH * 3 / 4, kSafeAreaTopHeight, 50, buttonHeight);
    [self.editButton setTitle:@"编辑" forState:UIControlStateNormal];
    self.editButton.backgroundColor = [UIColor purpleColor];
    MMViewBorderRadius(self.editButton, 6, 2, [UIColor blackColor]);
    
    UICollectionViewFlowLayout *flowLayout = [UICollectionViewFlowLayout new];
    flowLayout.minimumLineSpacing = 5;
    flowLayout.minimumInteritemSpacing = 5;
    flowLayout.headerReferenceSize = CGSizeMake(self.frame.size.width, 50);
    flowLayout.itemSize = CGSizeMake((SCREEN_WIDTH - 95)/4,(SCREEN_WIDTH - 95)/4);
    
    self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(40, kSafeAreaTopHeight + buttonHeight, SCREEN_WIDTH - 80, SCREENH_HEIGHT - kSafeAreaTopHeight - buttonHeight) collectionViewLayout:flowLayout];
    [self addSubview: self.collectionView];
    
    
    
    [self addSubview:self.editButton];
    
}

@end
